function bluebirdWindow(){}
bluebirdWindow.prototype={
	divX:0,
	divY:0,
	mouseX:0,
	mouseY:0,
	zindex:0,
	isMove:false,
	isBlock:true,
	canClose:true,
	w_title:'系统窗口',
	contentDivCss:'w_content',
	init:function(){
		var w_window=$C('div',{'class':'bluebirdWindow'});
		this.w_window=w_window;
		if(true==this.canClose){
			this.closeImg=$C('div',{'class':'closeimg'});
			switchEffect(this.closeImg,'closeimg_over');
			eve.observe(this.closeImg,'click',this.closeWindow,this);
			w_window.appendChild($C('div',{'class':'closediv'},this.closeImg));
		}
		this.w_window.appendChild(this.createHtml());
		this.contentDiv.style.width=this.w_width+'px';
		this.w_window.style.top=document.documentElement.scrollTop+100+'px';
		this.w_window.style.left='-1000px';
		this.w_window.style.zIndex=bluebirdWindow.prototype.zindex++;
		if(true==this.isBlock){
			this.block=$C('div',{'class':'shadow'});
			this.block.style.height=document.body.offsetHeight+'px';
			document.body.appendChild(this.block);
		}
		document.body.appendChild(this.w_window);
		var w_width=this.w_width||this.w_window.clientWidth;
		this.w_window.style.left=parseInt((document.body.clientWidth-w_width)/2)+'px';
		if(true==this.canClose){//如果这个窗口可以移动,加入可移动事件
			eve.observe(this.w_window.getElementsByTagName('td')[1],'mousedown',this.initDrag,this);
			eve.observe(this.w_window,'mousedown',this.checkIstop,this);
		}
	},
	createHtml:function(){
		this.contentDiv=$C('div',{'class':this.contentDivCss},this.innerDiv);
		return $C('table',{'cellPadding':'0','cellSpacing':'0'},$C('tbody',{},$C('tr',{},$C('td',{'class':'w_all'},$C('img',{'src':'images/window/lt_corner.gif'})),$C('td',{'class':'w_all t_bg'+((this.canClose)?' move':'')},$C('div',{'class':'w_title'},this.w_title)),$C('td',{'class':'w_all'},$C('img',{'src':'images/window/rt_corner.gif'}))),$C('tr',{},$C('td',{'class':'w_all l_bg'}),$C('td',{'class':'w_center'},this.contentDiv),$C('td',{'class':'w_all r_bg'})),$C('tr',{},$C('td',{'class':'w_all lrb_corner'}),$C('td',{'class':'w_all b_bg'}),$C('td',{'class':'w_all lrb_corner moveposition'}))));		
	},
	closeWindow:function(){
		eve.stopObserve(this.w_window.getElementsByTagName('td')[1],'mousedown',this.initDrag);
		removeDom(this.w_window);
		if(true==this.isBlock)	removeDom(this.block);
		for(var m in this)	this[m]=null;
	},
	checkIstop:function(){
		if(parseInt(this.w_window.style.zIndex)+1!=bluebirdWindow.prototype.zindex)	this.w_window.style.zIndex=bluebirdWindow.prototype.zindex++;//如果不是最顶层,置顶
	},
	initDrag:function(e){
		if(true==this.isMove)	return;
		this.isMove=true;
		var divPosition=this.getPosition(this.w_window);
		this.divX=divPosition[1];
		this.divY=divPosition[0];
		this.mouseX=e.clientX;
		this.mouseY=e.clientY;
		eve.observe(document.body,'mousemove',this.drag,this);
		eve.observe(document.body,'mouseup',this.stopDrag,this);
	},
	drag:function(e){
		var mx=e.clientX-this.mouseX;
		var my=e.clientY-this.mouseY;
		this.w_window.style.left=this.divX+mx+'px';
		this.w_window.style.top=this.divY+my+'px';
		this.divX+=mx;
		this.divY+=my;
		this.mouseX+=mx;
		this.mouseY+=my;
	},
	stopDrag:function(){
		eve.stopObserve(document.body,'mousemove',this.drag,this);
		eve.stopObserve(document.body,'mouseup',this.stopDrag,this);
		this.isMove=false;
	},
	getPosition:function(obj){
		return [obj.offsetTop,obj.offsetLeft];
	}
};
var bluebirdDialog=new Object();
bluebirdDialog.warn=function(str,cssName,titlestr,w_width){
	var frame=new bluebirdWindow();
	frame.w_width=w_width;
	frame.isBlock =false;
	frame.w_title=titlestr;
	frame.innerDiv=$C('table',{'width':'100%'},$C('tbody',{},$C('tr',{},$C('td',{'class':'w_imgtd '+cssName},str)),$C('tr',{},$C('td',{'class':'cen'},this.createButton('确定',frame.closeWindow.bind(frame),emptyFunc,frame)))));
	frame.init();	
}
bluebirdDialog.alert=function(str,w_width){
	this.warn(str,'w_alert','系统提示',w_width||300);
}
bluebirdDialog.error=function(str,w_width){
	this.warn(str,'w_error','出错了',w_width||300);
}
bluebirdDialog.ok=function(str,w_width){
	this.warn(str,'w_ok','成功了',w_width||300);
}
bluebirdDialog.info=function(str,w_width){
	this.warn(str,'w_info','系统消息',w_width||300);
}
bluebirdDialog.confirm=function(str,btnObj,w_width){
	var btnTd=$C('td',{'class':'cen'});
	var frame=new bluebirdWindow();
	for(var btn in btnObj)
		btnTd.appendChild(this.createButton(btn,btnObj[btn],frame.closeWindow.bind(frame)));
	frame.w_width=w_width||400;
	frame.w_title='网页对话框';
	frame.innerDiv=$C('table',{'width':'100%'},$C('tbody',{},$C('tr',{},$C('td',{'class':'w_imgtd w_confirm'},str)),$C('tr',{},btnTd)));
	frame.init();
}
bluebirdDialog.createButton=function(val,act,closeAct){
	var btn=$C('input',{'class':'btn','type':'button','value':val});
	eve.observe(btn,'click',act);
	eve.observe(btn,'click',closeAct);
	switchEffect(btn,'btn_over');
	return btn;
}
bluebirdDialog.html=function(inHtml,w_title,w_width,c_css,userCloseFunc){//userCloseFunc 自定义关闭事件
	var frame=new bluebirdWindow();
	frame.w_width=w_width||500;
	frame.isBlock=false;
	frame.w_title=w_title||'系统窗口';
	frame.contentDivCss=c_css||'w_content';
	//if(closeFunc)frame.closeWindow=userCloseFunc;
	frame.innerDiv=$C('table',{'width':'100%'},$C('tbody',{},$C('tr',{},$C('td',{},inHtml))));
	frame.init();
	if(true==userCloseFunc)
		return frame;
	else
		return frame.closeWindow.bind(frame);
}
bluebirdDialog.staticHtml=function(inHtml,w_title,w_width){
	var frame=new bluebirdWindow();
	frame.w_width=w_width||500;
	frame.w_title=w_title||'系统窗口';
	frame.canClose=false;
	frame.innerDiv=$C('table',{'width':'100%'},$C('tbody',{},$C('tr',{},$C('td',{},inHtml))));
	frame.init();
	return frame.closeWindow.bind(frame);
}